/*
 * @Description:
 * @version::
 * @Author: zhao
 * @Date: 2020-11-18 09:53:30
 * @LastEditors: zhao
 * @LastEditTime: 2020-12-12 11:34:03
 */
const mapUrl = "https://apis.map.qq.com";
const requestUrl = "https://dianliyou.com";
const _expand = [];
if (process.env.NOD_ENV === "production") {
  _expand.push("transform-remove-console");
}
export default {
  loading: true,
  // Disable server-side rendering (https://go.nuxtjs.dev/ssr-mode)
  ssr: false,

  // Global page headers (https://go.nuxtjs.dev/config-head)
  head: {
    title: "管理系统",
    meta: [
      { charset: "utf-8" },
      { name: "viewport", content: "width=device-width, initial-scale=1" },
      { hid: "description", name: "description", content: "" },
    ],
    link: [{ rel: "icon", type: "image/x-icon", href: "/favicon.ico" }],
    // script: [
    //     { src: 'https://cdn.jsdelivr.net/npm/echarts@4.1.0/dist/echarts.js'},
    //     { src: 'https://cdn.jsdelivr.net/npm/vue-echarts@4.0.2'}
    // ]
  },

  router: {
    extendRoutes(routes, resolve) {
      routes.push({ path: "/", redirect: "/login" });
    },
  },

  // Global CSS (https://go.nuxtjs.dev/config-css)
  css: [
    "element-ui/lib/theme-chalk/index.css",
    // 项目里要用的 CSS 文件
    "@/assets/css/common.scss",
    "@/assets/css/icon.css",
    { src: "swiper/css/swiper.css" },
  ],

  // Plugins to run before rendering page (https://go.nuxtjs.dev/config-plugins)
  plugins: [
    "@/plugins/element-ui",
    {
      src: "~/api/apiList.js",
      ssr: false,
    },
    {
      src: "@/plugins/swiper.js",
      ssr: false,
    },
    // {
    //   src: "@/plugins/vant-ui.js",
    //   ssr: false,
    // },
    "@/plugins/router",
    "@/plugins/Tmap",
    // vue全局指令-限制输入数字大小，小数点后几位
    {
      src: "@/directive/inputNumber/index.js",
      ssr: false,
    },
    { src: "@/plugins/popup.js", ssr: false },
    { src: "@/plugins/moment.js", ssr: false },
    { src: "@/plugins/vant_ui.js", ssr: false },
  ],
  // Auto import components (https://go.nuxtjs.dev/config-components)
  components: true,

  // Modules for dev and build (recommended) (https://go.nuxtjs.dev/config-modules)
  buildModules: [
    // https://go.nuxtjs.dev/typescript
    "@nuxt/typescript-build",
    "@aceforth/nuxt-optimized-images"
  ],
  optimizedImages: {
    optimizeImages: true
  },
  // Modules (https://go.nuxtjs.dev/config-modules)
  modules: ["@nuxtjs/proxy", "@nuxtjs/axios"],

  // Build Configuration (https://go.nuxtjs.dev/config-build)
  build: {
  transpile: [/^element-ui/],
    babel: {
      plugins: _expand,
    },
  },
  axios: {
    proxy: true,
    credentials: true,
  },
  server: {
    port: 9000,
    host: "0.0.0.0", //可用ip访问本地
  },
  proxy: {
    "/backmanageapi": {
      target: requestUrl,
      changeOrigin: true,
    },
    "/ws": {
      target: mapUrl,
      changeOrigin: true,
    },
  },
  env: {
    __ENV: process.env.__ENV,
  },
};
